<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <link rel="icon" href="/content/favicon.ico">
    <title>登录</title>

    <link href="/content/css/bootstrap3.3.5/bootstrap.min.css" rel="stylesheet">
    <link href="/content/js/jquery-toast/jquery.toast.min.css" rel="stylesheet">
    <link href="/content/customize/layui/css/layui.css" rel="stylesheet"/>
    <link href="/content/css/loaders.css" rel="stylesheet"/>
    <link href="/content/css/signin.css" rel="stylesheet"/>
</head>
<body class="bg-info login-bg">
<div class="login-wrap" data-VerifyCodeEnabled="false">
    <div class="login-success">
        <div class="login-user-boder">
            <div class="login-user-img"></div>
        </div>
        <div class="login-success-text">
            <p>===欢迎&nbsp;<span><i class="layui-icon layui-icon-username"></i><span
                    class="login-user-name">用户</span></span>&nbsp;登录===</p>
            <p class="masked">正在进入</p>
        </div>
    </div>
    <div class="text-left login-title">
        <h3><span id="appname"></span></h3>
    </div>
    <div class="login-content" style="margin-top: 30px;">
        <div class="col-sm-12">
            <form id="signinForm" action="/api/account/signin" method="post" data-jsonajax="true">
                <input id="returnurl" type="hidden" name="returnurl" value=""/>
                <div class="form-group orgname-group hide">
                    <div class="input-group">
                        <span class="input-group-addon"><i class="layui-icon layui-icon-group"></i></span>
                        <input type="hidden" name="orguniquename" value="xms"/>
                        <select class="form-control pl-0" name="OrgUniqueName" id="OrgUniqueName">
                            <option value="xms">xms</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon"><i class="layui-icon layui-icon-username"></i></span>
                        <input type="text" name="loginname" id="LoginName" autocomplete="off"
                               class="form-text loginname" placeholder="帐号" required autofocus/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">  <i class="layui-icon layui-icon-password"></i></span>
                        <input type="password" name="password" id="password" autocomplete="off"
                               class="form-text loginpwd" placeholder="密码" required/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">  <i class="layui-icon layui-icon-vercode"></i></span>
                        <input type="text" name="verifycode" id="verifycode" autocomplete="off"
                               class="form-text loginpwd" placeholder="验证码" required/>
                        <span class="input-group-addon">
                            <a href="javascript:getVerifyCode()">
                            <img id="verifyimg" style="margin-left:10px;"/>
                            </a>
                        </span>
                    </div>
                </div>
                <div class="form-group checkbox">
                    <label class="col-xs-offset-2">
                        <input type="checkbox" name="rememberme" checked/>&nbsp;&nbsp;记住我
                    </label>
                </div>

                <div class="form-group">
                    <div class="col-xs-offset-2">
                        <button class="btn login-submit login login-btn" type="submit">登录</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-sm-12 col-xs-12 col-lg-12 text-center versionnumber-text hide">版本：1.0</div>
    </div>
</div>
<div class="clearCacheBtn hide" id="clearCacheBtn">清除缓存</div>
<div class='authent'>
    <div class="loader" style="height: 44px;width: 44px;margin-left: 28px;">
        <div class="loader-inner ball-clip-rotate-multiple">
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <p>认证中...</p>
</div>
<script src="/content/js/jquery.min.js"></script>
<script src="/content/js/jquery-validate/jquery.validate.min.js"></script>
<script src="/content/js/jquery.form.js"></script>
<script src="/content/js/jquery-toast/jquery.toast.min.js"></script>
<script src="/content/js/xms.web.js"></script>
<script src="/content/js/xms.jquery.js"></script>
<script src="/content/js/jquery.cookie.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.effect.js"></script>
<script src="/api/global/settings"></script>

<script>
    var ORG_SERVERURL = '/xms';
    var model = $.urlParamObj(location.href);
    window.onload = function () {
        if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE6.0" || navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE7.0" || navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE8.0") {
            alert("为了您的更好体验，请使用IE9及以上版本浏览网页");
        }
    }

    function clearAllCookie() {
        var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
        if (keys) {
            for (var i = keys.length; i--;)
                document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString()
        }
        localStorage.clear();
    }

    function getVerifyCode() {
        document.getElementById("verifyimg").src = timestamp("/api/verify/randomimage/get");
    }

    //为url添加时间戳
    function timestamp(url) {
        var getTimestamp = new Date().getTime();
        if (url.indexOf("?") > -1) {
            url = url + "&timestamp=" + getTimestamp
        } else {
            url = url + "?timestamp=" + getTimestamp
        }
        return url;
    };
    $(function () {
        if (top.location != location) {
            top.location.href = location.href;
            return;
        }
        $('#appname').text(GLOBAL_SETTINGS.appname);
        $('title').text('登录' + GLOBAL_SETTINGS.appname);
        getVerifyCode();
        /*if (model.url) {
            model.url = decodeURIComponent(model.url);
            $('#returnurl').val(model.url || '');
        }*/
        var returnUrl = $('#returnurl').val();
        var actionPre = '/api/account/signin';
        var $OrgUniqueName = $('#OrgUniqueName');
        $OrgUniqueName.on('change', function (e) {
            //var val = $(this).val();
            //ORG_SERVERURL = '/' + val;
            //var action = '/' + val + actionPre;
            $('form').attr('action', actionPre);
        }).trigger('change');

        var debound = $.deboundsEvent(3000, true);
        $('form').submit(function () {
            var that = this;
            debound(function () {
                $('.login-wrap').addClass('test'); //倾斜特效
                setTimeout(function () {
                    $('.login-wrap').addClass('testtwo'); //平移特效
                }, 300);
                setTimeout(function () {
                    $('.authent').show().animate({right: -320}, {
                        easing: 'easeOutQuint',
                        duration: 600,
                        queue: false
                    });
                    $('.authent').animate({opacity: 1}, {
                        duration: 200,
                        queue: false
                    }).addClass('visible');
                }, 500);

                $(that).ajaxSubmit(function (response) {
                    setTimeout(function () {
                        $('.authent').show().animate({right: 90}, {
                            easing: 'easeOutQuint',
                            duration: 600,
                            queue: false
                        });
                        $('.authent').animate({opacity: 0}, {
                            duration: 200,
                            queue: false
                        }).addClass('visible');
                        $('.login-wrap').removeClass('testtwo'); //平移特效
                    }, 500);
                    setTimeout(function () {
                        $('.authent').hide();
                        $('.login-wrap').removeClass('test');
                        if (response.IsSuccess == true) {
                            $('.login-success').show();
                            $('.login-success').nextAll().hide();

                            $('.login-user-name').text($('#LoginName').val());
                            setTimeout(function () {
                                if (returnUrl) {
                                    location.href = returnUrl;
                                } else {
                                    location.href = ORG_SERVERURL;
                                }
                            }, 1000);

                        } else {
                            Xms.Web.Toast(response.ErrorMessage, false);
                            getVerifyCode();
                        }
                    }, 1500);

                });
            })
            //console.log(response);
            return false;
        });

        $('#clearCacheBtn').on('click', function () {
            clearAllCookie();
        })
    });
</script>
</body>
</html>